var model = {
    name: "",
    images: []
};

class Models{
    get list(){
        return this._list;
    }
    set list(item){
        if (this._list == undefined) {
            this._list = [];
        }
        if (item.length == undefined) {
            //object item
            this._list.push(item);
        } else {
            // array items
            var that = this;
            $.each(item, function(k,v){
                that._list.push(v);
            });
        }
        return this._list;
    }
    constructor() {
        this.initModels();
    }
    initModels(){
        this.list = [{
            name: "自定义PHP镜像",
            images: []
        },{
            name: "Yii发布的镜像",
            images: []
        }];
        this.refleshModelsList();
        this.selectNetwork();
    }
    initNetwork(){
        if($("input[name='network']:checked").val() == "1"){
            $(".d-form-create-network").css("display","block");
            $(".d-form-ext-network").css("display","none");
        } else {
            $(".d-form-create-network").css("display","none");
            $(".d-form-ext-network").css("display","block");
        }
    }
    selectNetwork(){
        this.initNetwork();
        var that = this;
        $("input[name='network']").click(function(){
            that.initNetwork();
        });
    }
    refleshModelsList(){
        $(".d-models ul").empty();
        var that = this;
        $.each(that.list, function(k,v){
            $(".d-models ul").append("<li><a>" + v.name + "</a></li>");
        });
    }
    add(){

    }
    delete(){

    }
}
var modelObject = new Models();